Closed Bug 1629419 Opened 5 years ago Closed 5 years ago

ClientWebGLContext.cpp: the 'empty' method should be used to check for emptiness instead of 'size'

Categories

(Developer Infrastructure :: Source Code Analysis, task)

task
Not set
minor

Tracking

(firefox79 fixed)

RESOLVED FIXED
mozilla79
Tracking Status
firefox79 --- fixed

People

(Reporter: Sylvestre, Assigned: nd419, Mentored)

References

(Blocks 1 open bug)

Details

(Keywords: good-first-bug, Whiteboard: [lang=C++])

Attachments

(1 file, 1 obsolete file)

+++ This bug was initially created as a clone of Bug #1626786 +++

Filling as a good first bug to learn workflows.

  if (notLost.info.error.size()) {
    ThrowEvent_WebGLContextCreationError(notLost.info.error);
    return false;
  }

should use .empty() instead

https://searchfox.org/mozilla-central/source/dom/canvas/ClientWebGLContext.cpp#759

As the change is trivial, it is just to learn how to contribute to Firefox.

Found by http://clang.llvm.org/extra/clang-tidy/checks/readability-container-size-empty.html

Tutorial to contribute:
https://firefox-source-docs.mozilla.org/tools/docs/contribute/how_to_contribute_firefox.html

Please don't ask for the bug to be assigned. It will be automatically assigned to the first patch.

Also, please only work on two max of such bugs.

Assignee: nobody → nd419
Status: NEW → ASSIGNED
Attachment #9157382 - Attachment is obsolete: true

Well done!

Could you please request the patch to land? It is explained in the documentation

Pushed by ccoroiu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f5eed997b258 Replaced size call with .empty r=handyman

Isn't this doing the opposite of what it should do?

if (notLost.info.error.size()) {
ThrowEvent_WebGLContextCreationError(notLost.info.error);
return false;
}

is not equivalent to

if (notLost.info.error.empty()) {
ThrowEvent_WebGLContextCreationError(notLost.info.error);
return false;
}

!!notLost.info.error.size() != notLost.info.error.empty()

Flags: needinfo?(sledru)
Flags: needinfo?(sledru) → needinfo?(davidp99)

Should it not have been

if (!notLost.info.error.empty()) {

(In reply to mac198442 from comment #7)

Should it not have been

if (!notLost.info.error.empty()) {

Yes sorry, I had this on my other revision but accidentally had this one accepted instead of the other.

Flags: needinfo?(nd419)

Yeah, I missed it -- as I said in my review, I thought the patches were identical but I had missed that this one was missing the '!'. nd419, you can just resubmit the working patch and I'll approve it. You should also choose "Abandon Revision" for the patch that I mistakenly approved. I see you had added a note after my approval saying that the patches weren't identical but I never saw it since I wasn't following the bug. Basically, we had bad luck. In the future, if you want to make sure that a reviewer sees an important comment on something that has been approved, you can always re-request a review with a note explaining the reason.

Flags: needinfo?(davidp99)
Attachment #9157367 - Attachment is obsolete: true
Attachment #9157382 - Attachment is obsolete: false
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla79
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: